package com.rosense.nfvo.util;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.UserGroupInformation;

public class Kbs2HdfsUtil {

	public static FileSystem getFileSystem() {
		try {
			System.setProperty("sun.security.krb5.debug", "true");
			System.setProperty("java.security.krb5.conf", Constants.krbconf);

			Configuration conf = new Configuration();
			conf.addResource(new Path(Constants.hdfs_conf));
			conf.addResource(new Path(Constants.core_conf));
			UserGroupInformation.setConfiguration(conf);
			UserGroupInformation ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(Constants.user, Constants.keytab);
			UserGroupInformation.setLoginUser(ugi);

			return  FileSystem.get(conf);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return null;
	}
	
}
